﻿Imports System.Data.OleDb
Imports System.Data

Public Class Join
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub


    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Dim myGUID = Guid.NewGuid()
        Dim newFileName As String = myGUID.ToString() & ".jpg"
        Dim fileLocationOnServerHardDisk = Request.MapPath("Photos") & "/" & newFileName
        f_Photo.SaveAs(fileLocationOnServerHardDisk)
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("SingleMomMemberConnectionString").ConnectionString)
        Dim SqlString As String = "Insert into Members(FirstName,LastName,Address,Phone,Email,AboutMe,Photo) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", tb_FirstName.Text)
        cmd.Parameters.AddWithValue("@f2", tb_LastName.Text)
        cmd.Parameters.AddWithValue("@f3", tb_Address.Text)
        cmd.Parameters.AddWithValue("@f4", tb_Phone.Text)
        cmd.Parameters.AddWithValue("@f5", tb_Email.Text)
        cmd.Parameters.AddWithValue("@f6", tb_AboutMe.Text)
        cmd.Parameters.AddWithValue("@f7", "Photos/" & newFileName)
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("Confirmation.aspx")

    End Sub
End Class
